package com.lmy.dp01.DAO;

import com.lmy.dp01.entity.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface StudentRepository extends JpaRepository<Student, Integer> {

    List<Student> findByNameLike(String teacherName);

    @Query(nativeQuery = true, value = "SELECT * FROM tb_student WHERE SUBSTRING(sno, 1, 4) = (SELECT MAX(SUBSTRING(sno, 1, 4)) FROM tb_student )ORDER BY sno DESC;")
    public List<Student> findMaxTno();

    @Query(nativeQuery = true, value = "select * from tb_student where name = :name")
    Student findByName(@Param("name") String name);

    public List<Student> findBySno(String sno);
}
